package com.wcl.demo.ui.activity;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.LayoutInflater;
import android.view.View;

import com.wcl.demo.R;
import com.wcl.demo.presenter.BasePresenter;
import com.wcl.demo.utils.ProgressUtils;
import com.wcl.demo.view.Titanic;
import com.wcl.demo.view.TitanicTextView;

import butterknife.Bind;
import butterknife.ButterKnife;

/**
 * Created by dllo on 15/11/16.
 */
public abstract class BaseActivity extends AppCompatActivity {

    protected String tag = getClass().getSimpleName();

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        initPresenter();
        setContentView(getLayout());
        ActivityControl.addActivity(tag, this);
        ButterKnife.bind(this);
        ProgressUtils.showProgress(this);
        initView();
        initData();
        ProgressUtils.dismissProgress();
    }

    /**
     * 初始化Presenter
     */
    protected void initPresenter() {

    }

    /**
     * 返回值为所要加载的布局文件
     *
     * @return
     */
    protected abstract int getLayout();

    /**
     * 初始化控件
     *
     * @return
     */
    protected abstract void initView();

    /**
     * 初始化数据
     */
    protected abstract void initData();


    @Override
    protected void onDestroy() {
        super.onDestroy();
        ActivityControl.removeActivity(tag);
    }
}
